<?php /*a:1:{s:91:"D:\down\PHPstudy\phpstudy_pro\WWW\APP\app_admin\tp5\application\index\view\login\login.html";i:1616828547;}*/ ?>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>Login Page</title>
		<!-- 样 式 文 件 -->
		<link rel="stylesheet" href="/pear/css/pear.css" />
		<link rel="stylesheet" href="/admin/css/other/login.css" />
		<script src="/static/js/jquery-3.3.1.min.js"></script>
		<script src="/static/js/particles.min.js"></script>
		<script src="/layui/layui.js"></script>
	</head>
    <!-- 代 码 结 构 -->
	<body background="/admin/images/background2.svg" style="background-size: cover;">
		<form class="layui-form" action="javascript:void(0);">
			<div class="layui-form-item">
				<img class="logo" src="/admin/images/logo.png" />
				<div class="title">Pear Admin</div>
				<div class="desc">
					明 湖 区 最 具 影 响 力 的 设 计 规 范 之 一
				</div>
			</div>

			<div class="layui-form-item">
				<input placeholder="账户" hover class="layui-input" id="name" />
			</div>

			<div class="layui-form-item">
				<input placeholder="密码" hover class="layui-input" id="password" />
			</div>

			<div class="layui-form-item">
				<div id="captchaCode"  <?php if(($show)): ?> show required="" <?php else: ?> hidden <?php endif; ?>>
					<input type="text" placeholder="验证码" class="layui-input"  name="captcha" id="captcha">
					<div id="myDiv" <?php if(($show)): ?> show <?php else: ?> hidden <?php endif; ?>>
						<br>
						<img src="<?php echo captcha_src(); ?>" onclick="updateCaptch()" alt="captcha" width="40px" height="60px" id="imgCaptcha"/>
					</div>
				</div>
			<br>

			<div class="layui-form-item">
				<button type="button" class="pear-btn pear-btn-success login" lay-submit lay-filter="login">
					登 入
				</button>
			</div>

			<input type="hidden" name="__token__" id="__token__" value="<?php echo htmlentities(app('request')->token()); ?>" />
		</form>
		<!-- 资 源 引 入 -->
		<script src="/pear/pear.js"></script>
		<script>
			layui.use(['form','jquery'], function() {
				var form = layui.form,$ = layui.jquery;
                // 登 录 提 交
				form.on('submit(login)', function(data) {
				    let name = $("#name").val();
				    let password = $("#password").val();
				    let token = $("#__token__").val();
				    let captcha = $("#captcha").val();
				    $.ajax({
						url : "<?php echo url('loginUser'); ?>",
                        data : {
                            name : name,
                            password :  password,
							__token__ : token,
                            captcha : captcha
						},
						type : "POST",
						dataType : "json",
						success (res) {
                            layer.msg(res.message);
						    if (res.code === 1) {
						        setTimeout(function(){
                                    window.location.href = "http://www.yd2021.com";
                                },1500);
							} else {
                                $("#imgCaptcha").attr("src","<?php echo captcha_src(); ?>");
                                $("#__token__").val(res.token);
                                if (res.show === true) {
                                    $("#captchaCode").show();
                                    $("#myDiv").show();
                                }
							}
						}
					});
					return false;
				});
			});

            function updateCaptch() {
                $("#imgCaptcha").attr("src","<?php echo captcha_src(); ?>");
            }
		</script>
	</body>
</html>
